<?
defined('_JEXEC') or die('Restricted access');

class CouponsHelper
{
   private static $extension ='com_coupons';
    
   public static function AddCategoriesSubmenu($submenu)
   {
            JSubMenuHelper::addEntry(JText::_('COM_COUPONS_COUPONS'), 'index.php?option='.self::$extension, $submenu == 'coupons');
            JSubMenuHelper::addEntry(JText::_('COM_COUPONS_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension='.self::$extension, $submenu == 'categories');
            // set some global property
            $document = JFactory::getDocument();
            if ($submenu == 'categories') 
                $document->setTitle(JText::_('COM_COUPONS_CATEGORIES'));
   }
   
   public static function GetCouponsCategories()
   {
            $db = JFactory::getDBO();
            
            $db->setQuery("SELECT * FROM #__categories WHERE extension='".self::$extension."'");
            $db->query();
            $categories = $db->loadAssocList();
            $options = array();
            if ($categories)
                foreach($categories as $category) 
                    $options[] = JHtml::_('select.option', 'value='.$category->title );
            return $categories;
   }
}
?>
